// File Name: led_tools.c
// Author: kukukukuku~
// Date: 2025-03-17

#include "stddef.h"
#include "./LED/inc/led_tools.h"

/**
 * @brief   LED呼吸灯模式GPIO配置
 * @param   gpioPort:       LED GPIO端口
 * @param   gpioPin:        LED GPIO引脚
 * @param   gpioPinSource:  LED GPIO引脚源
 * @param   gpioMux:        LED GPIO引脚复用
 * @retval  None
 * @note    None
*/
void led_breath_mode_gpio_config(gpio_type * const gpioPort, const uint32_t gpioPin, const gpio_pins_source_type gpioPinSource, const gpio_mux_sel_type gpioMux)
{
    if(gpioPort == NULL)
        return;
    
    gpio_init_type gpioInitStruct = 
    {
        .gpio_pins           = gpioPin,
        .gpio_out_type       = GPIO_OUTPUT_PUSH_PULL,
        .gpio_pull           = GPIO_PULL_NONE,
        .gpio_mode           = GPIO_MODE_MUX,
        .gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER,
    };
    
    gpio_init(gpioPort, &gpioInitStruct);
    gpio_pin_mux_config(gpioPort, gpioPinSource, gpioMux);
}


/**
 * @brief   LED闪烁灯/开关灯模式GPIO配置
 * @param   gpioPort:   LED GPIO端口
 * @param   gpioPin:    LED GPIO引脚
 * @retval  None
 * @note    None
*/
void led_blink_or_switch_mode_gpio_config(gpio_type * const gpioPort, const uint32_t gpioPin)
{
    if(gpioPort == NULL)
        return;
    
    gpio_init_type gpioInitStruct = 
    {
        .gpio_pins           = gpioPin,
        .gpio_out_type       = GPIO_OUTPUT_PUSH_PULL,
        .gpio_pull           = GPIO_PULL_NONE,
        .gpio_mode           = GPIO_MODE_OUTPUT,
        .gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER,
    };
    
    gpio_init(gpioPort, &gpioInitStruct);
}
